package com.jiang.专题.动态规划.Q397;

/**
 * @author Jiang
 * @version 1.0
 * @date 2025/02/26 14:39
 */
class Solution {
    public int integerReplacement(int n) {
        if (n == 1) return 0;
        if (n % 2 == 0) return 1 + integerReplacement(n / 2);
        return 2 + Math.min(integerReplacement(n / 2), integerReplacement(n / 2 + 1));
    }
}
